<template>
	<view>
		<view class="page">
			<view class="myhead">
				<view class="head-img"> 
					<img :src="userInfo.user_pic" alt="" v-if="userInfo.user_pic" />
					<img src="../../static/logo.png" alt="头像" v-else/>
				</view>
				<view class="head-name" v-if="userInfo.nick_name"><span>{{userInfo.nick_name}}</span></view>
				<view class="head-name" @click="login" v-else><span>点击登录</span></view>
				<view class="set-btn" @click="goMyset">
					<span class="iconfont icon-shezhi" ></span>
				</view>
			</view>
			<view class="myform">
				<view class="form-item" @click="toapply" >
					<view class="form-title">
						<span class="iconfont icon-biaodan" ></span> 申请接单
					</view>
					<view class="form-btn">
						<span class="iconfont icon-jiantou"></span>
					</view>
				</view>
				<view class="warn-title" >
					<span>问题请点击微信客服复制微信添加好友</span>
				</view>
				<view class="form-item" @click="showWeChatContact">
					<view class="form-title">
						<span class="iconfont icon-shejiaotubiao-01"></span> 微信客服
					</view>
					<view class="form-btn">
						<span class="iconfont icon-jiantou"></span>
					</view>
				</view>
				<view class="form-item" @click="toaboutAs">
					<view class="form-title">
						<span class="iconfont icon-guanyu"></span> 关于我们
					</view>
					<view class="form-btn">
						<span class="iconfont icon-jiantou"></span>
					</view>
				</view>
				<view class="form-item" @click="toproposal">
					<view class="form-title">
						<span class="iconfont icon-jianyi"></span> 投诉建议
					</view>
					<view class="form-btn">
						<span class="iconfont icon-jiantou"></span>
					</view>
				</view>
			</view>
			<view class="out-btn" @click="loginOut" v-if="userInfo.phoneNum">退出登录</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:null
			}
		}, 
		created(){
			//获取存储在storage中的userInfo的数据 name token userInfo
			this.userInfo = uni.getStorageSync("userInfo")
			
		},
		methods: {
			goMyset(){
				uni.navigateTo({
					url:'/pages/mySet/mySet'
				})
			},
			toapply(){
				uni.navigateTo({
					url:'/pages/apply/apply'
				})
			},
			toaboutAs(){
				uni.navigateTo({
					url:'/pages/aboutAs/aboutAs'
				})
			},
			toproposal(){
				uni.navigateTo({
					url:'/pages/proposal/proposal'
				})
			},
			login(){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			},
			loginOut(){
				uni.removeStorageSync('token')
				uni.removeStorageSync('userInfo')
				uni.reLaunch({
					url:'/pages/login/login'
				})
			},
			showWeChatContact() {
			      // 使用 uni.showModal 显示带有微信联系方式的提示框
			     uni.setClipboardData({
			     	data:"15733022390",
					showToast:true,
					success:(res) => {
							// log(res)
							uni.showToast({
								title:"复制微信成功"
							})
						}
			     })
			    }  
		}
	}
</script>

<style lang="scss" scoped>
.page{
	width: 100%;
	height: 100vh;
	background-color: #F2F2F2;
	.myhead{
		width: 100%;
		height: 210rpx;
		background-color: #B2CFED;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.head-name{
			span{
				color: #FFFFFF;
				font-size: 30rpx;
			}
			//让文字挨着头像
			margin-right: 400rpx;
		}
		.head-img{
			width: 100rpx;
			height: 100rpx;
			// background-color: pink;
			padding-left: 10rpx;
			img{
				width: 100rpx;
				height: 100rpx;
				//设置成圆形
				border-radius: 50%;
			}
		}
		.set-btn{
			// margin-right: 20rpx;
			span{
				font-size: 50rpx;
			}
			}
	}
	.myform{
		width: 100%;
		height: 600rpx;
		// background-color: pink;
		.warn-title{
			width: 95%;
			height: 80rpx;
			margin: 0 auto;
			margin-top: 20rpx;
			margin-bottom: -26rpx;
			background-color: #F2F2F2;
			line-height: 80rpx;
			background-color: #B2CFED;
			text-align: center;
			border-radius: 20rpx;
			font-weight: bold;
			letter-spacing: 5rpx;
		}
		.form-item{
			width: 95%;
			margin: 0 auto;
			height: 90rpx;
			line-height: 100rpx;
			background-color: white;
			margin-top: 30rpx;
			display: flex;
			border-radius: 20rpx;
			.form-title{
				margin-left: 20rpx;
			}
			.form-btn{
				margin-left: 500rpx;
			}
		}
		.form-item:last-child{
			margin-top: 0rpx;
			border-top: 1px solid gray;
		}
	}
	.out-btn{
		width: 95%;
		height: 80rpx;
		margin: 0 auto;
		margin-top:180rpx;
		background-color: #DF3939;
		line-height: 80rpx;
		text-align: center;
		border-radius: 50rpx;
		color: #FFFFFF;
		letter-spacing: 5rpx;
	}
}
</style>
